Execution Directives

Execution directives may be specified to compile and consult through :–/1. If, in the read phase of compile or consult, a term with principal functor :–/1 is read in, this term is executed directly via call/1. This enables the user to dynamically modify the environment, e.g. via op declarations (see Section [*]), asserts etc. :–/1 (P)

A point to note is that if the environment is modified as a result of an execution directive, the modifications are visible only in that environment. This means that consulted code, which runs in the environment in which the source program is read (and which is modified by such execution directives) feel the effects of such execution directives. However, byte code resulting from compilation, which, in general, executes in an environment different from that in which the source was compiled, does not inherit the effects of such directives. Thus, an op declaration can be used in a source file to change the syntax and allow the remainder of the program to be parsed according to the modified syntax; however, these modifications will not, in general, manifest themselves if the byte code is executed in another environment. Of course, if the byte code is loaded into the same environment as that in which the source program was compiled, e.g. through

| ?- compile(foo, bar), load(bar).
the effects of execution directives will continue to be felt.